package com.irdstudio.apicenter.frame.tag.bootstrap;

import org.apache.commons.lang3.StringUtils;

import com.irdstudio.apicenter.frame.core.jdbc.container.DataRow;

/**
 * 文本标签(即可放在TTable标签下也可单独使用)
 * 
 * @author guangming.li
 * @version 1.0
 * @date 2015-06-24
 */
public class TText extends TAbstractText {

	private static final long serialVersionUID = -6918427839260607211L;

	/**
	 * 渲染标签
	 */
	@Override
	public void renderTag(StringBuffer sb, DataRow dataRow) {
		sb.append("			<td align=\"").append(this.align).append("\">");
		if (StringUtils.isEmpty(this.getDictname())) {
			sb.append(dataRow.getValue(this.getId()));
		} else {
			// 如果有字典项，则用字典项进行转换
			sb.append(getDicOptionValue(this.getDictname(), dataRow.getValue(
					this.getId()).toString()));
		}
		sb.append("</td>");
	}

	@Override
	public Object clone() {

		TText tag = new TText();
		tag.label = this.label;
		tag.id = this.id;
		tag.defvalue = this.defvalue;
		tag.dictname = this.dictname;
		tag.align = StringUtils.isEmpty(this.align) ? "left" : this.align;
		return tag;
	}

}
